package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjInfoBean;
import com.koron.css2.newProjectCenter.mapper.PjInfoMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class PjInfoUpdate implements ServerInterface {

    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjInfoBean pjInfoBean = JsonUtils.objectToPojo(req.getData(),PjInfoBean.class);
            PjInfoMapper pjInfoMapper = factory.getMapper(PjInfoMapper.class);
            // 1. updateTime,updateAccount,updateName
            pjInfoBean.setUpdateInfo(userInfo);
            // 2. 更新数据
            pjInfoMapper.update(pjInfoBean);
            // 3. 返回结果
            return MessageBean.create(Constant.MESSAGE_INT_SUCCESS,"工程报装单条数据更新成功",null);
        } catch (Exception e) {
            logger.error("工程报装单条数据更新失败",e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL,"工程报装单条数据更新失败",null);
        }
    }
}
